﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RouteValidator
{
    public partial class ValidationReport : Form
    {
        public ValidationReport()
        {
            InitializeComponent();
        }

        private void ValidationReport_Load(object sender, EventArgs e)
        {
            lstReport.Items.Add("Validating Route Description at: " + Form1.mainForm.XmlPath);
            Validator v = new Validator(Form1.mainForm.XmlPath, lstReport);
            butExport.Enabled = false;

            if (v.ErrorCount > 0)
            {
                labErrors.Text = "Errors: " + v.ErrorCount.ToString() + "\t\tWarnings: " + v.WarningCount.ToString();
                lstReport.Items.Add("Validation Failed, Please amend Route Description before Export");
            }
            else
            {
                butExport.Enabled = true;
                lstReport.Items.Add((v.WarningCount > 0)?
                    "Validation Partially Successful, Please check warning messages":
                    "Validation Successful! Please click 'Export' to continue");
            }

        }

        private void ValidationReport_FormClosed(object sender, FormClosedEventArgs e)
        {            
            this.Hide();
            Form1.mainForm.Show();
        }

    }
}
